<template>
  <view class="definite">
    <u-navbar :is-back="true" title="实名认证" back-text="">
      <view
        class="slot-right"
        style="width: 100%; display: flex; justify-content: flex-end"
      >
        <view style="padding: 0rem 0.5rem; display: flex; align-items: center">
          <!-- <view style="
font-size: 0.75rem;
font-family: PingFang SC;
font-weight: 300;
color: #02AF74;" >员工规则</view> -->

          <!-- <image style="width: 0.7rem;
height: 0.5rem;
padding: 0.3rem;" src="../../../style/image/my/bottomArrow.jpg" alt=""> -->
        </view>
      </view>
    </u-navbar>
    <view class="title">身份认证</view>
    <view class="item">
      <span style="display: flex">
        <span>
          <image class="image" src="../../style/image/my/A33.jpg" alt="">
        </span>
        <view style="padding-left: 0.8rem">
          <view class="name">{{info.realName==''||info.realName==null?'暂未设置':info.realName}}</view>
          <view class="num">{{identify==null?'暂无':identify}}</view>
        </view>
      </span>
      <span  @click="goidenify" >
        <view class="btn">{{this.identify==null?'去认证':'去修改'}}</view>
      </span>
    </view>
     <view class="title">支付宝提现账号</view>
    <view class="item">
      <span style="display: flex">
        <span>
          <image class="image" src="../../style/image/order/allAppily.png" alt="">
        </span>
        <view style="padding-left: 0.8rem">
          <view class="name">{{info.blackAccountName==''||info.blackAccountName==null?'暂未设置':info.blackAccountName}}</view>
          <view class="num">{{appily==null?'暂无':appily}}</view>
        </view>
      </span>
      <span @click="goAppilfy"  >
        <view class="btn">{{this.appily==null?'去认证':'去修改'}}</view>
      </span>
    </view>
  </view>
</template>

<script lang='ts' >
import { Component, Prop, Vue, Watch, Emit } from "vue-property-decorator";

import { findUserInfo } from "../../utils/uniApi";

import uNavbar from '@/uview-ui/components/u-navbar/u-navbar.vue'
import { AppModule } from "../../store/modules/app";

@Component({
  //   @Component  是一个装修器   不可以在下面写语句
  name: "test",
   components:{
    'u-navbar':uNavbar
  }
})
export default class extends Vue {
  @Prop({
    type: String, // 父组件传递给子组件的数据类型
    required: false, // 是否必填
    default: " ", // 默认值， 如果传入的是 Object，则要 default: ()=>({}) 参数为函数
  })
  msg!: string;

  public info = {
    id: "",
    parentId: "", //上级用户ID
    parentPhone: "", //	父级账号（拥有该字段的人代表是子账号）
    pwd: "", //	密码
    payPwd: "", //	支付密码
    roleId: "", //	角色
    roleEndTime: "", //	会员到期时间
    phone: "", //手机号
    card: "", //证件号
    realName: "", //真实姓名
    registTime: "", //	注册时间
    blackAccountName: "", //支付宝用户名（姓名）
    blackNum: "", //	支付宝账号
    headImg: "", //	头像
    nickInitial: "", //	昵称首字母
    nickName: "HIPPY", //	昵称
    oId: "", //	所属品牌
    remarks: "", //余额
    count: "", //推荐人数
    clientid: "", //设备ID
    recCode: "", //推荐码
    blance: "", //余额
    supportStaffQq: "", //	客服QQ
    supportStaffPhone: "", //客服电话
    role: {
      roleName: "暂未设置会员等级", //会员名称
    }, //会员信息
  };

  public identify = "";

  public appily = "";

  created() {}

  mounted() {
    //  console.log('父组件传递的参数:',this.$parent)   //暂时不考虑
    uni.showLoading({
      title: "加载中",
    });
    this.findUserInfoM();
  }

  findUserInfoM() {
    let params = {
      userId:
        uni.getStorageSync("userId") == ""
          ? ""
          : parseInt(uni.getStorageSync("userId")),
    };
    findUserInfo(params).then((res: any) => {
      console.log("个人信息res", res);
      this.info = res.data.data;

      this.identify = res.data.data.card;

      if(this.identify!=null){

            this.identify = this.identify.replace(
        /^(.{4})(?:\d+)(.{4})$/,
        "$1******$2"
      );

      }

    
      this.appily = res.data.data.blackNum;

      //  if(this.identify!=null){
      
      //       this.identify = this.identify.replace(
      //   /^(.{4})(?:\d+)(.{4})$/,
      //   "$1******$2"
      // );

      // }

      console.log(this.appily, "this.appilythis.appily");

      setTimeout(() => {
        uni.hideLoading();
      }, 300);

      // this.src = res.data.data.headImg;
    });
  }

   onPullDownRefresh() {
    console.log("refresh");

    setTimeout(function () {
      uni.redirectTo({
        url: "../../pages/aiplay/atte",
      });
      uni.stopPullDownRefresh();
    }, 1000);

  }

  goidenify() {
    console.log("qweqweqwe123");

    if (this.identify == null) {
      console.log("去认证");
      uni.navigateTo({
        url: "../../pages/aiplay/idtiilfy",
      });
    } else {

      console.log("去修改");
        uni.navigateTo({
        url: "../../pages/aiplay/idtiilfy",
      });

       let info={
          realName:this.info.realName,
          card:this.info.card, //证件号
          blackAccountName:this.info.blackAccountName, //支付宝用户名（姓名）
          blackNum:this.info.blackNum //	支付宝账号
      }

      console.log(info,'infoinfo')

      AppModule.idenifyInfoAction(info)

    }

  }

  goAppilfy() {
    console.log("qweqweqwe123");

    //  appily
    if (this.appily == null) {

      console.log("去认证");

         uni.navigateTo({
        url: "../../pages/aiplay/aiplay",
      });

      

    } else {
      console.log("去修改");

      let info={
          realName:this.info.realName,
          card:this.info.card, //证件号
          blackAccountName:this.info.blackAccountName, //支付宝用户名（姓名）
          blackNum:this.info.blackNum //	支付宝账号
      }

      console.log(info,'infoinfo')

      AppModule.idenifyInfoAction(info)

         uni.navigateTo({
        url: "../../pages/aiplay/aiplay",
      });

    }
  }
}
</script>

<style  scoped>
.definite {
  font-family: PingFang SC;
  background: #f3f5f7;
  height: 100%;
}
uni-page-body {
  height: 100%;
}
.title {
  text-align: center;
  font-size: 0.7rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: #666666;
  padding: 1.2rem 0 0.8rem 0;
}
.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0.5rem;
  padding: 0.8rem 0.5rem;
  background: #ffffff;
  border-radius: 0.3rem;
}
.image {
  width: 1.7rem;
  height: 1.7rem;
  /* background: #aaaaaa; */
  border-radius: 50%;
}
.name {
  font-size: 0.7rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: #000000;
}
.num {
  padding-top: 0.2rem;
  font-size: 0.6rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: #999999;
}
.btn {
  width: 3.3rem;
  height: 1.35rem;
  line-height: 1.35rem;
  text-align: center;
  background: #02af74;
  border-radius: 1rem;
  font-size: 0.7rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: #ffffff;
  margin-right: 0.5rem;
}
</style>